package event;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class EventConfig extends Config{
	private static final String EVENT_CONFIG_FILE = "SequenceConfig.xml";
	private static final String SEQUENCE = "Sequence";
	private static final String MAX = "Max";
	private static final String MIN = "Min";
	private static final String HOME = "Home";
	private static final String MODE = "Mode";
	private Sequence sequence = new Sequence();
	public EventConfig()
	{
		super(EVENT_CONFIG_FILE);
		loadConfig();
	}
	protected void loadConfig()
	{
		readFile();
		loadSequence();
	}
	//load the configurations in SequenceConfig.xml
	private void loadSequence()
	{
		Element sequenceEntry = (Element)config.getElementsByTagName(SEQUENCE).item(0);
		Node maxLength = sequenceEntry.getElementsByTagName(MAX).item(0);
		sequence.maxLength = Integer.parseInt(maxLength.getFirstChild().getNodeValue());
		Node minLength = sequenceEntry.getElementsByTagName(MIN).item(0);
		sequence.minLength = Integer.parseInt(minLength.getFirstChild().getNodeValue());
		Node homeNode = sequenceEntry.getElementsByTagName(HOME).item(0);
		sequence.home = homeNode.getFirstChild().getNodeValue();
		Node modeNode = sequenceEntry.getElementsByTagName(MODE).item(0);
		sequence.mode = Integer.parseInt(modeNode.getFirstChild().getNodeValue());
	}
	public Sequence getSequence()
	{
		return sequence;
	}
}
